<?
if (!defined("LEVEL") || LEVEL < 30 || !defined("OK")) { header('location: http://'.$_SERVER["HTTP_HOST"].''); exit; }
/*
CREATE TABLE `meniu` (
`id` INT NOT NULL AUTO_INCREMENT ,
`name` VARCHAR( 30 ) NOT NULL DEFAULT 'Meniu',
`url` VARCHAR( 100 ) NOT NULL DEFAULT '?id,1',
`order` INT NOT NULL DEFAULT '1',
`command` TEXT NULL ,
UNIQUE (
`id` ,
`url`
)
) ENGINE = MYISAM ;


INSERT INTO `meniu` ( `id` , `name` , `url` , `order` , `command` )
VALUES (
NULL , 'Home', '?id,1', '1', NULL
);

DELETE FROM `meniu` WHERE `meniu`.`id` =2 AND CONVERT( `meniu`.`url` USING utf8 ) = '?id,1' LIMIT 1 ;

UPDATE `meniu` SET `url` = '?home' WHERE `meniu`.`id` =1 AND CONVERT( `meniu`.`url` USING utf8 ) = '?id,1' LIMIT 1 ;

SELECT * FROM `meniu` ORDER BY `meniu`.`order` DESC LIMIT 0 , 30

POST new url
Array ( [submeniu] => 3 [name] => Auto vol.2 [url] => http://www.mrcbug.com [action] => Įrašyti )
*/
?>

<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td class="title">Pavadinimas</td>
		<td class="title">Url</td>
		<td class="title">Vieta</td>
		<td class="title">Veiksmas</td>
	</tr>
<?
	$sql = $db->uzklausa("SELECT * FROM `meniu` ORDER BY `meniu`.`order` LIMIT 0 , 30");
	$text = ''; $submeniu = '';
	if (mysql_num_rows($sql) > 0) {
		while ($row = mysql_fetch_assoc($sql)) {
		$submeniu .= "<option value='".$row['id']."'>".$row['name']."</option>\n";
		echo "
	<tr>
		<td class='sarasas'><a href='?id,46;a,11;s,".$row['id']."'>".(($row['url']=='')?'+':'-')." ".$row['name']."</a></td>
		<td class='sarasas'><a href='".$row['url']."'>".$row['url']."</a></td>
		<td class='sarasas'>".$row['order']."</td>
		<td class='sarasas'>
		<a href='".url("t,".$row['id']."")."' title='Trinti' onclick=\"return confirm('Ar tikrai norite trinti?') \"><img src='images/icons/cancel.png' class='middle' border='0'/></a> 
		<a href='".url("r,".$row['id']."")."' title='Redaguoti'><img src='images/icons/pencil.png' class='middle' border='0'/></a> 
		<a href='".url("u,".$row['id']."")."' title='Į viršų'><img src='images/icons/arrow_up.png' class='middle' border='0'/></a> 
		<a href='".url("d,".$row['id']."")."' title='Žemyn'><img src='images/icons/arrow_down.png' class='middle' border='0'/></a>
		</td>
	</tr>
		";
		}
	}
	else { klaida("Klaida","komentarų nėra"); }
?>
	</tr>
</table>
<hr/>
<?
$text .= '<form name="url_add" action="?id,46;a,11" method="post">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
	<tr>
		<td width="100px" class="sarasas">Submeniu:</td>
		<td class="sarasas"><select size="1" name="submeniu"><option value="" selected="selected">---</option>
		'.$submeniu.'
		</select></td>
	</tr>
	<tr>
		<td class="sarasas">Pavadinimas:</td>
		<td class="sarasas"><input name="name" value="" type="text"></td>
	</tr>
	<tr >
		<td class="sarasas">url:</td>
		<td class="sarasas"><input name="url" value="" type="text"></td>
	</tr>
	<tr>
		<td class="sarasas"></td>
		<td class="sarasas"><input name="action" value="Įrašyti" type="submit"></td>
	</tr>
</table>
</form>';
hide("Naujas meniu",$text,true,"Naujas įrašas");

print_r($_POST);
?>
